#include <string>
#include <list>

#define DATA_PATH "../data/"

using namespace std;

namespace database {

	//static const char* DATA_PATH = "../data/";

	struct Newsgroup {
		int 	id;
		string 	name;

		bool operator<(Newsgroup rhs) {
			return (id < rhs.id);
		}
	};

	struct Article {
		int 	id;
		string 	date;
		string 	author;
		string 	title;
		string 	text;

		bool operator<(Article rhs) {
			return (id < rhs.id);
		}
	};

	typedef pair<Newsgroup, list<Article> > ng_list_item;
	typedef list<ng_list_item> ng_list;
	typedef list<Article> art_list;
	typedef Article art_list_item;

	class Database
	{

		public:
		Database();
		~Database();

		bool addNewsgroup(string);
		bool deleteNewsgroup(int);
		list<Newsgroup> listNewsgroups();

		bool addArticle(int, string, string, string, string);
		bool deleteArticle(int, int);
		list<Article> listArticles(int);
		Article getArticle(int, int);

		private:
		ng_list ngs;

		void init_db();
		ng_list::iterator findNewsgroup(int);
		ng_list::iterator findNewsgroup(string);
		int largestNewsgroupID();
		int largestArticleID(art_list&);
	};

}
